<?php
require('config.php');

        $user_id=$_REQUEST['user_id'];
        $orderId=$_REQUEST['orderId'];
        $goodsId=$_REQUEST['goodsId'];
        $shopId=$_REQUEST['shopId'];
        $packScore=$_REQUEST['packScore'];
        $timeScore=$_REQUEST['timeScore'];
        $serviceScore=$_REQUEST['serviceScore'];
        $time=date('Y-m-d H:i:s');
		$sql="select * from `".$oto."_goods_appraises` where `userId`='".$user_id."' and orderId='{$orderId}' and goodsId='{$goodsId}' and shopId='{$shopId}'";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$appraises_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(!isset($appraises_info))
		{
			$sql="INSERT INTO ".$oto."_goods_appraises (`userId`,`orderId`,`goodsId`,`shopId`,`packScore`,`timeScore`,`serviceScore`,`createTime`) VALUES ('$user_id','$orderId','$goodsId','$shopId','$packScore','$timeScore','$serviceScore','$time')";
            $result=$db->query($sql);
            if($result)
            {
            	$data[0]['pan']=1;
            }
            else
            {
            	$data[0]['pan']=0;
            }
		}
		else
		{
			$sql="update ".$oto."_goods_appraises set packScore='{$packScore}',timeScore='{$timeScore}',serviceScore='{$serviceScore}' where userId='{$user_id}' and orderId='{$orderId}' and goodsId='{$goodsId}' and shopId='{$shopId}'";
			$result=$db->query($sql);
			if($result)
            {
            	$data[0]['pan']=1;
            }
            else
            {
            	$data[0]['pan']=0;
            }
		}
		echo json_encode($data);
?>